#include "widget.h"
#include "ui_widget.h"
#include <QGridLayout>
#include <QPushButton>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    QGridLayout* layout = new QGridLayout(this);

    QPushButton* button = new QPushButton("1");
    QPushButton* button2 = new QPushButton("2");
    QPushButton* button3 = new QPushButton("3");
    QPushButton* button4 = new QPushButton("3");

    layout->addWidget(button, 0, 0);
    layout->addWidget(button2, 0, 1);
    layout->addWidget(button3, 1, 0);
    layout->addWidget(button4, 1, 1);

    //设置水平的拉伸系数
    layout->setColumnStretch(0, 1);
    layout->setColumnStretch(1, 2);
}

Widget::~Widget()
{
    delete ui;
}

